# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo08
# Description:
# Author:       98745
# Date:         2019/3/16
#-------------------------------------------------------------------------------

from twisted.internet import protocol,reactor
from time import ctime
port=9876
class MyProtocol(protocol.Protocol):
    def connectionMade(self):
        client=self.transport.getPeer().host
        print('客户端',client,'已经连接')
    def dataReceived(self, data):
        self.transport.write(ctime().encode(encoding='utf-8')+b''+data)
factory=protocol.Factory()
factory.protocol=MyProtocol
reactor.listenTCP(port,factory)
reactor.run()